import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
NProgress.configure({ // NProgress Configuration
  showSpinner: false
})
// import {getToken} from '@storage/token'
// import {getUserinfo} from '@srv/auth.js';
// import { useSettings } from '@store'
  
// import { pvStat } from './pv_stat';

function initHooks(router) {
  router.beforeEach(async (to, from, next) => {
    NProgress.start()

    const {
      name,
      meta: {title}
    } = to;

    const cfgs = window.$cfgs;
    document.title = title ? `${title} - ${cfgs.title}` : `${cfgs.title}`

    next();
  })

  router.afterEach((to, from, failure) => {
    if (!failure) {
      NProgress.done()
      // pvStat(from, to)
    }
  })
}

export {
  initHooks
}
